cmake_minimum_required(VERSION 2.6)
find_package(PkgConfig)

PROJECT(libmali C)
INCLUDE(GNUInstallDirs)

CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/pkgconfig/egl.pc.cmake"
	"${CMAKE_CURRENT_BINARY_DIR}/egl.pc" @ONLY)
CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/pkgconfig/gbm.pc.cmake"
	"${CMAKE_CURRENT_BINARY_DIR}/gbm.pc" @ONLY)
CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/pkgconfig/glesv2.pc.cmake"
	"${CMAKE_CURRENT_BINARY_DIR}/glesv2.pc" @ONLY)

INSTALL(FILES "${CMAKE_CURRENT_SOURCE_DIR}/include/mali.icd"
DESTINATION "${CMAKE_INSTALL_SYSCONFDIR}/OpenCL/vendors/")

IF(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/lib/${CMAKE_LIBRARY_ARCHITECTURE}/libmali-midgard.so")
INSTALL(FILES "${CMAKE_CURRENT_SOURCE_DIR}/lib/${CMAKE_LIBRARY_ARCHITECTURE}/libmali-midgard.so"
DESTINATION "${CMAKE_INSTALL_LIBDIR}")
ENDIF()
IF(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/lib/${CMAKE_LIBRARY_ARCHITECTURE}/libmali-midgard-r1p0.so")
INSTALL(FILES "${CMAKE_CURRENT_SOURCE_DIR}/lib/${CMAKE_LIBRARY_ARCHITECTURE}/libmali-midgard-r1p0.so"
DESTINATION "${CMAKE_INSTALL_LIBDIR}")
ENDIF()
IF(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/lib/${CMAKE_LIBRARY_ARCHITECTURE}/libmali-midgard-4th.so")
INSTALL(FILES "${CMAKE_CURRENT_SOURCE_DIR}/lib/${CMAKE_LIBRARY_ARCHITECTURE}/libmali-midgard-4th.so"
DESTINATION "${CMAKE_INSTALL_LIBDIR}")
ENDIF()
IF(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/lib/${CMAKE_LIBRARY_ARCHITECTURE}/libmali-utgard.so")
INSTALL(FILES "${CMAKE_CURRENT_SOURCE_DIR}/lib/${CMAKE_LIBRARY_ARCHITECTURE}/libmali-utgard.so"
DESTINATION "${CMAKE_INSTALL_LIBDIR}")
ENDIF()

INSTALL(FILES "${CMAKE_CURRENT_BINARY_DIR}/egl.pc"
"${CMAKE_CURRENT_BINARY_DIR}/gbm.pc"
"${CMAKE_CURRENT_BINARY_DIR}/glesv2.pc"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig/")

INSTALL(FILES "${CMAKE_CURRENT_SOURCE_DIR}/include/gbm.h"
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/")

INSTALL(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/EGL"
"${CMAKE_CURRENT_SOURCE_DIR}/include/GLES"
"${CMAKE_CURRENT_SOURCE_DIR}/include/GLES2"
"${CMAKE_CURRENT_SOURCE_DIR}/include/GLES3"
"${CMAKE_CURRENT_SOURCE_DIR}/include/KHR"
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/")

